package com.sgb.kjwl.viewmodel.lookingforAJob;

import androidx.databinding.ObservableField;

import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.model.entity.FindJobRequestEntity;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.repository.HomeRepertory;
import com.sgb.kjwl.view.ui.activity.lookingforAJob.LookingforAJobActivity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class LookingforAJobModel extends BaseViewModel {

    public ObservableField<FindJobRequestEntity> filterJson = new ObservableField<FindJobRequestEntity>(new FindJobRequestEntity());


    private LookingforAJobActivity activity;
    private HomeRepertory repertory;

    public LookingforAJobModel(LookingforAJobActivity activity) {
        this.activity = activity;
        this.repertory = repertory;
    }

    public void getFilterTypeModel() {

        APIManager.getInstance().getPickAPI().tenderNewTypeList().enqueue(new Callback<BaseEntity<List<PickSelectEntity>>>() {
            @Override
            public void onResponse(Call<BaseEntity<List<PickSelectEntity>>> call, Response<BaseEntity<List<PickSelectEntity>>> response) {
                if (response.body() == null || response.body().getState() == null) {
                    return;
                }

                if (response.body().getState().equals(APIManager.RESPONSE_OK)) {
//                    activity.showTypeView();
                }
            }

            @Override
            public void onFailure(Call<BaseEntity<List<PickSelectEntity>>> call, Throwable t) {

            }
        });
    }

    private int index = 1;

    public void getList(boolean isLoadMore) {
        if (isLoadMore) {
            index = index + 1;
        } else {
            index = 1;
        }

    }
}
